<?php
class Captcha_model extends CI_Model{
    private $_table='captcha';
    public $captcha=array();
    public function get_captcha(){
        $query=$this->db->get($this->_table);
        $this->captcha=$query->result_array();
        return $this->captcha;
    }
    public function get_captcha_check($params=array()){
        foreach ($this->captcha as $index=>$captcha){
            if(($params['time']-$this->captcha[$index]['time'])<7200 && strcasecmp($this->captcha[$index]['word'],$params['word'])==0 && strcmp($this->captcha[$index]['ip'],$params['ip'])==0)
                    return true;
        }
        return false;
    }
    
    public function insert_captcha($params=array()){
        $query=$this->db->insert($this->_table,$params);
    }
}
